package com.gushenge.core.base.fragment

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.IntegerRes
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import com.kingja.loadsir.core.LoadSir
import com.gushenge.core.base.viewmodel.BaseViewModel


/**
 * 作者　: hegaojian
 * 时间　: 2019/12/12
 * 描述　: ViewModelFragment基类，自动把ViewModel注入Fragment和Databind注入进来了
 * 需要使用Databind的清继承它
 */
abstract class BaseVmDbFragment<VM : BaseViewModel, DB : ViewDataBinding>( var layoutId :Int) : BaseVmFragment<VM>() {

    lateinit var db: DB
    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        db = DataBindingUtil.inflate(inflater,layoutId, container, false)
        loadSir = LoadSir.getDefault().register(db.root
        ) {
            reloadClick()
        }

        db.lifecycleOwner = this
        return loadSir.loadLayout
    }

    abstract  fun reloadClick()
}